<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="assets/css/layui.css">
    <link rel="stylesheet" href="assets/css/login.css">
    <link rel="icon" href="/favicon.ico">
    <title>管理后台</title>
</head>
<body class="login-wrap">
    <div class="login-container">
        <form class="login-form" id="myForm" method="post" enctype="multipart/form-data" action="/merchant/register">
            <div class="input-group">
                <input type="text" name="code" id="username" class="input-field">
                <label for="username" class="input-label">
                    <span class="label-title">用户名</span>
                </label>
            </div>
            <div class="input-group">
                <input type="password" name="pwd" class="input-field">
                <label for="password" class="input-label">
                    <span class="label-title">密码</span>
                </label>
            </div>
            <div class="input-group">
                <input type="text" name="name" class="input-field">
                <label for="username" class="input-label">
                    <span class="label-title">昵称</span>
                </label>
            </div>
            <div class="input-group">
                <input type="file" name="file" class="input-field">
                <label for="password" class="input-label">
                    <span class="label-title">头像</span>
                </label>
            </div>
            <input type="submit" class="login-button" value="注册"/>
        </form>
    </div>
</body>
<script src="assets/layui.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.js"></script>
<script>

    $("#myForm").submit(function () {
        $(this).ajaxSubmit({
            success: function (data) {
                console.log(data);
                if (data.success) {
                    alert("注册成功");
                    window.location.href = "login.html"
                } else {
                    alert("注册失败");
                }
            },
            error: function (err) {
            },
            clearForm: true
        });
        return false;   //阻止表单默认提交
    });
</script>
</html>